import modal from "./modal";

export default {
  install(Vue) {
    Vue.prototype.$modal = modal;
    Vue.filter("dateFormat", function (date) {
      date = new Date(date);
      let y = date.getFullYear();
      let m = date.getMonth() + 1;
      m = m < 10 ? ('0' + m) : m;
      let d = date.getDate();
      d = d < 10 ? ('0' + d) : d;
      let h = date.getHours();
      h = h < 10 ? ('0' + h) : h;
      let minute = date.getMinutes();
      minute = minute < 10 ? ('0' + minute) : minute;
      let second = date.getSeconds();
      second = second < 10 ? ('0' + second) : second;
      return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
    });
    Vue.filter("numberFilter", function (value) {
      if (value < 10000) {
        return value;
      } else {
        return (value + "").substr(0, 1) + "." + (value + "").substr(1, 1) + "万";
      }
    });
    Vue.filter("imgSrcFormat", function (src) {
      let suffix = src.substr(src.lastIndexOf(".") + 1);
      return 'http://localhost:8963/' + suffix + '/' + src;
    });
  },
};
